package jp.co.menox.controller.tmserver.borrow;

import java.util.Map;

import jp.co.menox.controller.tmserver.TmServerControllerBase;
import jp.co.menox.tmcommon.model.Lending;
import jp.co.menox.tmserver.service.CategoryService;
import jp.co.menox.tmserver.service.LendingService;

import org.slim3.controller.Navigation;

/**
 * 借りたいもの予約画面
 * @author
 *
 */
public class BorrowingReserveController extends TmServerControllerBase {

    protected LendingService service;
    protected CategoryService categoryService;
    {
        service = new LendingService();
        categoryService = new CategoryService();
    }
    

    @Override
    public Navigation run() throws Exception {

        String lendingId = request.getParameter("lendingId");
        long id = Long.parseLong(lendingId);
        Lending model = service.select(id);
        if (model == null) {
            return forward("internal_error.jsp");
        }

        // 表示用mapの取得
        Map<Long, String> categoryMap = categoryService.getCategoryMap();
        Map<Long, String> userMap = userService.getUserMap();
        // 表示用変数設定
        requestScope("lending", model);
        requestScope("cateMap", categoryMap);
        requestScope("userMap", userMap);
        
        return forward("borrowingReserve.jsp");
    }

}
